/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * http://indepthcode.blogspot.com/2012/05/jpa-ejemplo-sencillo.html
 */
package com.prueba.models;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.TableGenerator;


/**
 *
 * @author Administrador
 */
@Entity
public class OmniBus implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator="BUS_SEQ")
    @TableGenerator(name="BUS_SEQ", table="tbsequence", pkColumnName="BUSES", allocationSize=1)
    @Column(name="BUS_ID", nullable=false)
    private Long id;
    
    private String placa;
    private String marca;
    private String modelo;
    private String anho;
    
   @OneToMany(fetch= FetchType.LAZY, cascade= CascadeType.PERSIST, mappedBy="omnibus",
           targetEntity=Viaje.class)
    private List<Viaje> viajes;

    public OmniBus() {
    }

    public OmniBus(String placa, String marca, String modelo, String anho) {
        this.placa = placa;
        this.marca = marca;
        this.modelo = modelo;
        this.anho = anho;
    }

    

   
   
    
   
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OmniBus)) {
            return false;
        }
        OmniBus other = (OmniBus) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.prueba.models.OmniBus[ id=" + id + " ]";
    }
    
}
